package com.ky.mylibrary;
 
import android.util.Log;
import android.widget.Toast;
 
import com.alibaba.fastjson.JSONObject;
 
import io.dcloud.feature.uniapp.annotation.UniJSMethod;
import io.dcloud.feature.uniapp.bridge.UniJSCallback;
import io.dcloud.feature.uniapp.common.UniModule;
 
/**
 * @author han
 * @date 2022/2/26 17:57
 * @desc
 */
public class MyModule extends UniModule {
    private static final String TAG = "MyModule";
 
    @UniJSMethod(uiThread = true)
    public void sayhello(JSONObject options, UniJSCallback callback) {
        Log.e(TAG, "testAsyncFunc--"+options);
        if(callback != null) {
            String name = options.getString("name");
            Toast.makeText(mUniSDKInstance.getContext(), name, Toast.LENGTH_SHORT).show();
            JSONObject data = new JSONObject();
            data.put("code", "success");
            data.put("message", "我是李四");
            callback.invoke(data);
            //callback.invokeAndKeepAlive(data);
        }
    }
}